package com.it.lock.controller;


import com.it.lock.service.RedisLockService;
import com.it.lock.service.RedissonLockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Scope("prototype") //配置为多例
public class Index {

    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Autowired
    RedisLockService redisLockService;
    @Autowired
    RedissonLockService redissonLockService;

    @RequestMapping("/lock")
    @Scope("prototype") //配置为多例
    public String test() throws InterruptedException {
        String result = redisLockService.getLock();
        return result;

    }
    @RequestMapping("/lock2")
    @Scope("prototype") //配置为多例
    public String test2() throws InterruptedException {
        String result = redisLockService.getLock2();
        return result;

    }

    @RequestMapping("/redisson")
    public String redisson(){
        redissonLockService.getRedisLock();
        return "ok";

    }





}
